package cn.iocoder.yudao.module.xhyy.dal.mysql.exam;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.xhyy.controller.app.exam.vo.AppExamPageReqVO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.exam.ExamDO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.knowledge.KnowledgeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.xhyy.controller.admin.exam.vo.*;

/**
 * 试卷资源 Mapper
 *
 * @author duanxinli
 */
@Mapper
public interface ExamMapper extends BaseMapperX<ExamDO> {

    default PageResult<ExamDO> selectPage(ExamPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExamDO>()
                .likeIfPresent(ExamDO::getExamName, reqVO.getExamName())
                .eqIfPresent(ExamDO::getGrade, reqVO.getGrade())
                .likeIfPresent(ExamDO::getBookName, reqVO.getBookName())
                .eqIfPresent(ExamDO::getSort, reqVO.getSort())
                .orderByAsc(ExamDO::getGrade)
                .orderByAsc(ExamDO::getChapter));
    }
    default PageResult<ExamDO> selectPage(AppExamPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExamDO>()
                .likeIfPresent(ExamDO::getExamName, reqVO.getExamName())
                .eqIfPresent(ExamDO::getGrade, reqVO.getGrade())
                .likeIfPresent(ExamDO::getBookId, reqVO.getBookId())
                .eqIfPresent(ExamDO::getSort, reqVO.getSort())
                .orderByDesc(ExamDO::getId));
    }

}